import { ApiProperty } from "@nestjs/swagger";
import { ArrayMinSize, IsArray, IsDefined, IsNotEmpty, IsNumber, IsString, ValidateNested, IsInt, Min, Max } from "class-validator";
import { Type } from "class-transformer";

export class TagDto {

	@ApiProperty({ description: '标签名称' })
	@IsDefined()
	@IsString({ message: '标签名称必须是字符串' })
	@IsNotEmpty({ message: '标签名称不能为空' })
	readonly name: string;

	@ApiProperty({ description: 'x坐标' })
	@IsDefined()
	@IsNumber({}, { message: 'x坐标必须是数字' })
	readonly x: number;

	@ApiProperty({ description: 'y坐标' })
	@IsDefined()
	@IsNumber({}, { message: 'y坐标必须是数字' })
	readonly y: number;

	@ApiProperty({description: '方位',})
	@IsDefined()
	@IsString({ message: '方位必须是字符串' })
	readonly position: string;

	// 标签类型 - 房间类型
	@ApiProperty({ description: '标签类型' })
	@IsDefined()
	@IsString({ message: '标签类型必须是字符串' })
	readonly roomType: string;
}

export class AccessTagDto {
	// 关联的房主id
	@ApiProperty({ description: '户型ID' })
	@IsDefined()
	@IsNumber({}, { message: '户型ID必须是数字' })
	houseId: number;

	// 标签 由多个组成，单个标签依据TagEntity
	@ApiProperty({ description: '标签' })
	@IsDefined()
	// 判断tags列表长度
	@IsArray()
	@ArrayMinSize(1, { message: '标签列表不能为空' }) // 确保列表至少有一个元素
	// 判断tags列表中每个元素的类型是否为TagDto
	@ValidateNested({ each: true })
	@Type(() => TagDto)
	tags: TagDto[]
}
